--- layout: post author: "Ed" title: "Savings and Dep" --- 2018-08-14-Visualising-Savings-And-Depreciation-Curves.utf8.md

In this post we continue our Mankiw, Romer and Weil marathon by visualising countries’ saving and depreciation curves, derived from the Solow and Augmented Solow model, using MRW’s dataset on economic growth with the help of Plotly and Crosstalk.

Calculating alpha and beta

First, we need to estimate the model to derive empirical estimates of \(\alpha\) and \(\beta\). MRW calculate both parameters using both a restrict and un-restricted model but choose to stick with the restricted parameter estimates so we do the same.

Running the restricted regressions just involves subtracting our previous regressors from each other. Here, we use sym and !! to ensure the quasiquotation filter expects works (this is analogous to the more lengthy version we used before where we’d code each model separately):

Now, we collect results using collect.results defined previously and repeat the above for the Augmented model.

Calculating \(\alpha\) for the classical Solow model was a pretty simple affair as we know that the regression coefficient is equal to \(\frac{\alpha}{1-\alpha}\). The Augmented model is a little trickier since we’re solving a set of simultaneous equations. However, the equations describing \(\alpha\) and \(\beta\) are symmetric so we can just swap round y and x in the mutate function.

We use spread here because we want each estimated coefficient to have its own column - an alternative would be to use some form of apply across rows.

subset estimation_type model_type alpha beta
OECD Restricted Classic 0.60 NA
Intermediate Restricted Classic 0.59 NA
Non-Oil Restricted Classic 0.36 NA
Intermediate Restricted Augmented 0.30 0.29
Non-Oil Restricted Augmented 0.27 0.31
OECD Restricted Augmented 0.37 0.14

One of the drawbacks of MRW’s data partitioning discussed previously is that countries aren’t partitioned into mutually exclusive groups. This is a bit of a pain because it means we effectively have multiple \(\alpha\)s and \(\beta\)s for any country which is in more than one group. For instance, the United Kingdom is included in every category by MRW so should we calculate its saving curve with an \(\alpha\) of 0.6, 0.59 or 0.36?

To overcome this we can return to the mutually exclusive partitions we created previously when we explored clustering the dataset.

Therefore, we repeat the above but with our new ‘club’ factor. In hindsight, using more functions would have been a lot quicker here:

subset estimation_type model_type alpha beta
Oil Restricted Classic 7.77 NA
Developing Restricted Classic 0.36 NA
Intermediate Restricted Classic 0.52 NA
Rich Restricted Classic 0.36 NA
Developing Restricted Augmented 0.13 0.27
Intermediate Restricted Augmented 0.30 0.25
Oil Restricted Augmented 0.99 -1.80
Rich Restricted Augmented 0.37 0.14

Next, we run a quick sanity check by comparing the estimates. It seems like dropping Oil is a good idea as these give pretty crazy results (somewhat predictably).

model_type subset alpha beta type
Classic Developing 0.36 NA New
Classic Intermediate 0.52 NA New
Classic Rich 0.36 NA New
Augmented Developing 0.13 0.27 New
Augmented Intermediate 0.30 0.25 New
Augmented Rich 0.37 0.14 New

We can visualise the differences using Plotly and plot_new_vs_old which we also defined in a previous post:

The \(\alpha\) estimates are pretty different to MRW’s original results which is a little surprising considering the underlying regression estimates seemed to be quite similar when we plotted them in the last post. Furthermore, differentiating the \(\alpha\) formula with respect to \(x\), our regression estimates, gives us \(\frac{1}{(1+x)^2}\) which suggests that \(\alpha\) is less sensitive to any given change in \(x\) than \(x\) itself i.e. \[1 \geq\frac{1}{(1+x)^2} \quad \forall \space x\]

This could be because the restricted regression set-up we’re employing effectively compounds all the estimated coefficient differences into one parameter.

Moving onto the Augmented model and the estimates begin to look similar to Mankiw, Romer and Weil’s:

Plotting classical saving and depreciation curves

Now that we have estimated our \(\alpha\) and \(\beta\) parameters, we can generate the necessary curves.

First, we create a vector of capital levels, \(k\), for each country and use left_join to include country specific variables such as s and n_g_d. Next, we use gsub to reformat the club factor entries so that we can perform another left join and add our estimated \(\alpha\)s and \(\beta\)s to the relevant countries depending on which ‘club’ they’re in.

Finally, we calculate the savings curve using the formula \(sk^\alpha\) and effective depreciation curve \((n + g + d)k\). As a (limited) test to ensure we’ve done everything correctly we calculate \(k^*\) and \(s^*\), the steady state levels of capital accumulation and corresponding savings curve point, which should hopefully correspond to where a country’s saving and depreciation curve meet.

k country 1985 s n_g_d club model_type alpha beta savings_curve depreciation_curve k_star s_star
7.0 U. Arab Emirates 18513 0.26 NA oil Classic 7.77 NA 976467.17 NA NA NA
8.5 Iceland NA 0.29 NA oil Augmented 0.99 -1.80 2.41 NA NA NA
4.5 Belgium 14290 0.23 0.06 rich Augmented 0.37 0.14 0.41 0.25 9.96 0.55
10.5 Malaysia 5788 0.23 0.08 intermediate_no_oil Augmented 0.30 0.25 0.47 0.86 4.42 0.36
10.5 Morocco 2348 0.08 0.08 intermediate_no_oil Augmented 0.30 0.25 0.17 0.79 1.16 0.09

We now have all the information we need to plot each countries’ curves. To demonstrate the difference between subsets we use facet_wrap(~club). The Crosstalk library lets us highlight individual countries within a plot and compare across multiple plots throughout the post.

First, the classic Solow model savings curves:

The differences between the rich, developing and intermediate savings curves demonstrate visually that the Solow model predicts conditional rather than unconditional convergence. The fact that intermediate countries’ savings curves appear to be higher than the rich countries, whilst puzzling, is coherent with the Solow model.

Now, we add depreciation curves as well as markers for \(k^*\) and \(s^*\):

The above plot is a little messy, so here we just show the curves’ intersection:

Plotting augmented saving curves

Now we can do the same but with the Augmented Solow model:

Comparing the two together:

This plot supports MRW’s conclusion that human capital can help explain differences in income. The addition of school in the regression equation and therefore \(\beta\) in the Augmented Solow model now means that rich countries’ savings curves appear above the intermediate countries as we’d most likely expect. Furthermore, it seems like the poor countries have gotten poorer.

Conclusion

We’ve plotted the savings and depreciation curves of the Solow and Augmented Solow model. Whilst the plots are interactive to a degree, thanks to Plotly and Crosstalk, it’d be interesting to allow users to input their own parameters for \(\alpha\), \(\beta\), \(s\), \((n + g + d)\) - unfortunately this would require Shiny which I’m reluctant to use given GitHub Pages’ static hosting.

Again our visualisations and tweaks of MRW’s original paper broadly reflect their own findings. Part I of this in depth MRW marathon can be found here, followed by Part II and Part III.